#ifndef __TRAP_H_
#define __TRAP_H_

#include "types.h"


struct trapframe {
	// kernel stack of this app
	uint64 kstack;
	// pc after trap
	uint64 epc;
	uint64 ra;
	// user stack of this app
	uint64 sp;
	uint64 gp;
	uint64 tp;
	uint64 t0;
	uint64 t1;
	uint64 t2;
	uint64 s0;
	uint64 s1;
	uint64 a0;
	uint64 a1;
	uint64 a2;
	uint64 a3;
	uint64 a4;
	uint64 a5;
	uint64 a6;
	uint64 a7;
	uint64 s2;
	uint64 s3;
	uint64 s4;
	uint64 s5;
	uint64 s6;
	uint64 s7;
	uint64 s8;
	uint64 s9;
	uint64 s10;
	uint64 s11;
	uint64 t3;
	uint64 t4;
	uint64 t5;
	uint64 t6;
};


extern void trap_init();
extern void trap_entry();
extern void trap(struct trapframe *tf_ptr);
extern void trap_ret_user();
extern void trap_end(struct trapframe *tf_ptr);
extern void syscall(struct trapframe *tf_ptr);

#endif
